<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>v-for,v-if</title>
    <style>

    </style>
</head>
<body>
    <div id="app1">	
        <p>姓名：{{fullName}}</p>
        <input type="button" value="修改姓名" @click="changeName">
    </div>
</body>
</html>
<script src="js/vue.js"></script>
<script>

let vm = new Vue({
    el:"#app1",
    data:{       
       firstname:"玉桂",
       lastname:"高"
    },
    computed:{
    //    fullName:function(){
    //         return this.lastname+"·"+this.firstname;
    //    }

        fullName:{
            set:function(newVal){
                console.log("set",newVal);
                [this.lastname,this.firstname] = newVal.split("·");
            },
            get:function(){
                return  this.lastname+"·"+this.firstname;
            }
        }
    },
    methods:{
        changeName(){
            this.fullName = "高·玉桂斯基"
        }
    }
});


</script>